module Spiced
  module Instance
    class Person
      attr_accessor :smokes, :kind
      def initialize(kind=nil)
        @kind = kind
        if block_given?
          yield(self)
        end
      end
    end
    # 
    # person = Person.inspice('comic',:name => "Lucky", :last_name => "Luke", :is_cool? => true) do |ll|
    #   ll.smokes = 'cigarettes'
    # end
    # 
    # p person
    # => <Person:0x9128 @kind="comic", @smokes="cigarettes", @name="Lucky", @last_name="Luke", @is_cool=true>
    # 
    # person = Person.inspice('drama',:name => "Lucky", :last_name => "Luke", :is_cool? => true) do |ll|
    #   ll.smokes = 'cigarettes'
    #   ll.kind   = 'comic'
    # end
    # 
    # p person
    # => #<Person:0xb4dc @last_name="Luke", @name="Lucky", @is_cool=true, @smokes="cigarettes", @kind="comic">
    # 
    # person = Person.inspice('comic',:name => "Lucky", :last_name => "Luke", :is_cool? => true)
    # 
    # p person
    # => #<Person:0xad5c @last_name="Luke", @name="Lucky", @is_cool=true, @smokes="cigars", @kind="comic">
    # 
    # person = Person.new('friendly') do |f|
    #   f.smokes = false
    # end
    # 
    # p person.kind
    # => "friendly"
    # p person.smokes
    # => false
    # p person
    # => #<Person:0x88e0 @smokes=false, @kind="friendly">
    # 
    # person = Person.inspice('comic',:name => "Lucky", :last_name => "Luke", :says => Proc.new {|obj,str| "#{obj.name} says #{str}"})
    # p person.says[person,'hi there']
    # => "Lucky says hi there"
    #
    # class Person;end
    # 
    # person = Person.inspice(:name => "Lucky", :last_name => "Luke", :is_cool? => true)
    # p person
    # => #<Person:0xb93c @name="Lucky", @last_name="Luke", @is_cool=true>
    # p person.name
    # => "Lucky"
    # p person.last_name
    # => "Luke"
    # p person.is_cool? 
    # => true
    # 
    # person = Person.inspice(:name => "Lucky", :last_name => "Luke", 
    #                         :is_cool? => true, :track_spices => true)
    # p person.spices_added
    # => ["is_cool?", "is_cool=", "last_name=", "name", "name=", "last_name"]
    # 
    # class Person
    #   attr_accessor :smokes
    # end
    # 
    # person = Person.inspice(:name => "Lucky", :last_name => "Luke", :is_cool? => true) do |ll|
    #   ll.smokes = 'cigarettes'
    # end
    # 
    # p person
    # => #<Person:0x9eac @is_cool=true, @smokes="cigarettes", @name="Lucky", @last_name="Luke">
    # p person.smokes
    # => "cigarettes"
    # person.smokes = 'cigars'
    # p person.smokes
    # => "cigars"
    #
  end
end